import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 引入element-ui
import ElementUI from 'element-ui';
import './assets/font/iconfont.css'
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import axios from 'axios';
import { Loading } from 'element-ui'
axios.defaults.baseURL="http://121.41.51.231:5000/api/private/v1/";

// AXIOS的拦截器
// 每次发请求之前都会触发
axios.interceptors.request.use((config)=>{
  Loading.service();
  config.headers.Authorization  = sessionStorage.getItem("token")
  return config;
})
// 每次发请求之后都会触发
axios.interceptors.response.use((config)=>{
  if(config.data.meta.status == 200){

  }else{
    router.push("/Login");
  }
  Loading.service().close();
  return config;
})


Vue.prototype.axios = axios;

Vue.config.productionTip = false

new Vue({
  router,
  store,
  //创建了一个app标签
  render: h => h(App) 
}).$mount('#app')
